home *** CD-ROM | disk | FTP | other *** search
/ Disc to the Future 2 / Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin / MAC / THINKC / TCL1 / CTRACE2_ / CTRACE.REA < prev   
Text File  |  1990-12-10  |  3KB  |  117 lines

  1. CTrace README
  2.  
  3. This is a revamp of the CTrace upload I submitted from the article:
  4.  
  5. CTRACE: A MESSAGE LOGGING CLASS
  6. by William D. Cramer, Dr. Dobbs Journal #170 (November 1990), 
  7. p. 44-55, 116-120.
  8.  
  9. I have put the different source code in their proper files and
  10. have constructed a proper .rsrc file for the TestApp. Here are 
  11. a few important points from the article to properly implement CTrace
  12. in your application.
  13.  
  14. RESOURCES
  15. I copied and modified the resource file Pedestal.╣.rsrc into which I put:
  16.  
  17. Resource ID        Type        Description
  18.  
  19. 2000            MENU        Titled "Trace", with the items
  20.                                 Show (command 2000) and
  21.                                 Mask (command 2001)
  22.     NB: make sure in ResEdit to use the "Menu" Menu to 
  23.     "Edit Menu & MDEF ID..." to 2000 and 1 respectively 
  24.         
  25. 1                MBAR        add menu res ID 2000
  26.  
  27. 2000            DLOG        coordinates (14,34), (508,286)
  28.                             procID 1, marked as visible,
  29.                             linked to DITL 2000
  30. 2000            DITL        buttons OK and Cancel (items 1 and 2)
  31.                             checkboxes Errors, Warnings, Info,
  32.                             Function Entry, Function Exit (items
  33.                             3 through 7), plus 27 additional
  34.                             checkboxes (items 8 through 34)
  35.                             titled Undefined and marked as disabled
  36.                             (you edit these yourself for your trace
  37.                             masks)
  38. 2000            WIND        titled "Trace Log" at coordinates
  39.                             (16,52) (330, 220), procID 8, marked
  40.                             as not visible, with goAwayFlag enabled.
  41.  
  42.  
  43. TRACE MASKS
  44.  
  45. You define the up to 32 trace masks (5 of which are already defined).
  46. You define a new hex trace mask in CTrace.h such as,
  47.  
  48. #define T_PICT_REDRAW    (0x00002000) /* screen refresh logging */
  49.  
  50. then, for example, insert the following code at the desired point
  51.  
  52. gTrace->Trace( T_PICT_REDRAW, "Refreshing the screen" );
  53.  
  54. or,
  55.  
  56. gTrace->Trace( T_FUNC_IN, "Entering LoopEndlessly() method" );
  57.  
  58. If you add a new mask you should change a DITL checkbox for your new mask.
  59. DITL #3 corresponds to 0x00000001, DITL #4 corresponds to 0x00000002, etc.
  60.  
  61.  
  62. ADDING CTrace TO CApplication
  63.  
  64. struct CYourApp : CApplication {
  65.     CTrace    *itsTraceLog;
  66.     ...
  67. };
  68.  
  69.  
  70. INITIALIZING CTrace
  71.  
  72. itsTraceLog = new ( CTrace );
  73. itsTraceLog->ITrace( numberOfRecordsToLog );
  74.  
  75.  
  76.  
  77. ADDITIONS TO UpdateMenus() METHOD FOR YOUR APPLICATION
  78.  
  79. /** UpdateMenus -- Updates the Trace portion of the menus. **/
  80. void CTestApp::UpdateMenus (void)
  81. {
  82.     inherited::UpdateMenus ();
  83.     gBartender->EnableMenu (TRACE_MENU_ID);
  84.     gBartender->EnableCmd (TRACE_MENU_SHOW);
  85.     gBartender->EnableCmd (TRACE_MENU_MASK);
  86.     if (itsTraceLog->IsItVisible ())
  87.         gBartender->CheckMarkCmd (TRACE_MENU_SHOW, TRUE);
  88.     else
  89.         gBartender->CheckMarkCmd (TRACE_MENU_SHOW, FALSE);
  90. }
  91.  
  92.  
  93. ADDITIONS TO DoCommand() METHOD FOR YOUR APPLICATION
  94.  
  95.     case TRACE_MENU_SHOW :
  96.         itsTraceLog->ToggleTraceWindow ();
  97.         break;
  98.     case TRACE_MENU_MASK :
  99.         itsTraceLog->SetTraceMask ();
  100.         break;
  101.     default :
  102.         inherited::DoCommand (command);
  103.  
  104.  
  105. OTHER NOTES
  106. The gTrace->Trace() method uses varargs() which can have up to 200 characters.
  107. The author suggests that once debugging is completed, you can leave the Trace
  108. object in your code but just edit the MBAR resource so that the Trace menu
  109. doesn't show up. Since the default trace mask is empty, you don't use up any
  110. memory, and you can just add the resource back if you decide to debug again.
  111.  
  112. I hope this is useful. Get the article if you have further questions.
  113. Cheers,
  114.  
  115. David McCormick
  116. MIT-EAPS Geology
  117. dmac@athena.mit.edu